package observer_pattern.v2;

import java.util.ArrayList;
import java.util.List;

/**
 * 抽象通知者接口
 * @author ricejson
 */
public abstract class Subject {
    protected String name;
    protected List<Observer> observerList = new ArrayList<>();
    protected String subjectState;

    public Subject(String name) {
        this.name = name;
    }

    public void setSubjectState(String subjectState) {
        this.subjectState = subjectState;
    }

    public String getSubjectState() {
        return subjectState;
    }

    public abstract void attach(Observer observer);
    public abstract void detach(Observer observer);
    public abstract void broadcast();
}
